home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / DeathLaser.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  5.6 KB  |  174 lines

  1. class classes.shots.DeathLaser
  2. {
  3.    var x;
  4.    var y;
  5.    var id;
  6.    var dir;
  7.    var eight;
  8.    var clip;
  9.    var axis;
  10.    var type;
  11.    var ep;
  12.    var xMov = 0;
  13.    var yMov = 0;
  14.    var Name = "deathLaser";
  15.    var power = 40;
  16.    var yank = false;
  17.    var c = 0;
  18.    var blastDirArray = ["L","R","U","D","LU","RU","RD","LD"];
  19.    function DeathLaser(px, py, pDir, peight, pid)
  20.    {
  21.       this.x = px;
  22.       this.y = py;
  23.       this.id = pid;
  24.       this.dir = pDir;
  25.       this.eight = peight;
  26.       _root.d = _root.d + 1;
  27.       this.clip = _root.attachMovie("deathLaser","deathLaser" + this.id + "Clip",_root.d + 1000);
  28.       this.clip._x = this.x;
  29.       this.clip._y = this.y;
  30.       this.clip.id = this.id;
  31.       if(this.dir == "U")
  32.       {
  33.          this.axis = "y";
  34.          this.yMov = -15;
  35.          this.xMov = 0;
  36.          this.y += 15;
  37.       }
  38.       else if(this.dir == "D")
  39.       {
  40.          this.axis = "y";
  41.          this.yMov = 15;
  42.          this.xMov = 0;
  43.          this.y -= 15;
  44.       }
  45.       else if(this.dir == "R")
  46.       {
  47.          this.axis = "x";
  48.          this.yMov = 0;
  49.          this.xMov = 15;
  50.          this.x -= 15;
  51.       }
  52.       else
  53.       {
  54.          this.axis = "x";
  55.          this.yMov = 0;
  56.          this.xMov = -15;
  57.          this.x += 15;
  58.       }
  59.       if(this.eight)
  60.       {
  61.          this.type = _root.randRange(1,3);
  62.       }
  63.       else
  64.       {
  65.          this.type = _root.randRange(1,2);
  66.       }
  67.       if(this.type == 2 || this.type == 3)
  68.       {
  69.          this.ep = _root.randRange(10,40);
  70.          this.ep *= 1 / _root.dif.speed;
  71.       }
  72.       else
  73.       {
  74.          this.ep = 100;
  75.       }
  76.       if(this.type == 3)
  77.       {
  78.          this.clip.eight = true;
  79.       }
  80.       this.xMov *= _root.dif.speed;
  81.       this.yMov *= _root.dif.speed;
  82.       this.clip.gotoAndStop(this.dir);
  83.       this.xMov *= _root.randRange2(0.95,1.05);
  84.       this.yMov *= _root.randRange2(0.95,1.05);
  85.    }
  86.    function hit()
  87.    {
  88.       this.yank = true;
  89.    }
  90.    function main()
  91.    {
  92.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  93.       {
  94.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  95.          this.yank = true;
  96.       }
  97.       if(this.x > 1050 || this.x < -50 || this.y > 650 || this.y < -50)
  98.       {
  99.          this.yank = true;
  100.       }
  101.       this.x += this.xMov;
  102.       this.y += this.yMov;
  103.       this.c = this.c + 1;
  104.       if(this.c >= this.ep)
  105.       {
  106.          this.yank = true;
  107.          if(this.type == 2)
  108.          {
  109.             _root.audio.playLevel3("deathLaserSplit" + (random(3) + 1),_root.randRange(16,21));
  110.             if(this.axis == "x")
  111.             {
  112.                _root.enemyShotID = _root.enemyShotID + 1;
  113.                _root["deathLaser" + _root.enemyShotID] = new classes.shots.DeathLaser(this.x,this.y,"U",false,_root.enemyShotID);
  114.                _root.addEnemyShot("deathLaser" + _root.enemyShotID);
  115.                _root.enemyShotID = _root.enemyShotID + 1;
  116.                _root["deathLaser" + _root.enemyShotID] = new classes.shots.DeathLaser(this.x,this.y,"D",false,_root.enemyShotID);
  117.                _root.addEnemyShot("deathLaser" + _root.enemyShotID);
  118.                _root.enemyShotID = _root.enemyShotID + 1;
  119.                _root["deathNode" + _root.enemyShotID] = new classes.shots.DeathNode(this.x,this.y,_root.enemyShotID);
  120.                _root.addEnemyShot("deathNode" + _root.enemyShotID);
  121.             }
  122.             else
  123.             {
  124.                _root.enemyShotID = _root.enemyShotID + 1;
  125.                _root["deathLaser" + _root.enemyShotID] = new classes.shots.DeathLaser(this.x,this.y,"R",false,_root.enemyShotID);
  126.                _root.addEnemyShot("deathLaser" + _root.enemyShotID);
  127.                _root.enemyShotID = _root.enemyShotID + 1;
  128.                _root["deathLaser" + _root.enemyShotID] = new classes.shots.DeathLaser(this.x,this.y,"L",false,_root.enemyShotID);
  129.                _root.addEnemyShot("deathLaser" + _root.enemyShotID);
  130.                _root.enemyShotID = _root.enemyShotID + 1;
  131.                _root["deathNode" + _root.enemyShotID] = new classes.shots.DeathNode(this.x,this.y,_root.enemyShotID);
  132.                _root.addEnemyShot("deathNode" + _root.enemyShotID);
  133.             }
  134.          }
  135.          else
  136.          {
  137.             _root.enemyShotID = _root.enemyShotID + 1;
  138.             _root["deathNode" + _root.enemyShotID] = new classes.shots.DeathNode(this.x,this.y,_root.enemyShotID);
  139.             _root.addEnemyShot("deathNode" + _root.enemyShotID);
  140.             var _loc4_ = random(2) != 0 ? false : true;
  141.             if(_loc4_)
  142.             {
  143.                _root.audio.playLevel3("deathLaser8WayRev",_root.randRange(13,17));
  144.             }
  145.             else
  146.             {
  147.                _root.audio.playLevel3("deathLaser8Way",_root.randRange(13,17));
  148.             }
  149.             var _loc3_ = 0;
  150.             while(_loc3_ < 8)
  151.             {
  152.                _root.enemyShotID = _root.enemyShotID + 1;
  153.                _root["deathBlast" + _root.enemyShotID] = new classes.shots.DeathBlast(this.x,this.y,this.blastDirArray[_loc3_],_loc4_,_root.enemyShotID);
  154.                _root.addEnemyShot("deathBlast" + _root.enemyShotID);
  155.                _loc3_ = _loc3_ + 1;
  156.             }
  157.          }
  158.       }
  159.       if(this.yank)
  160.       {
  161.          _root.removeEnemyShot("deathLaser" + this.id);
  162.          this.yank = false;
  163.       }
  164.       if(random(5) == 0)
  165.       {
  166.          _root.fxID = _root.fxID + 1;
  167.          _root["deathLaserTrail" + _root.fxID] = new classes.fx.DeathLaserTrail(this.x,this.y,this.dir,_root.fxID);
  168.          _root.addFX("deathLaserTrail" + _root.fxID);
  169.       }
  170.       this.clip._x = this.x;
  171.       this.clip._y = this.y;
  172.    }
  173. }
  174.